#!/bin/bash
Z=$1
[ -z "$Z" ] && echo "Syntax: $0 zonename" && exit 0
MASTER=`dig @localhost -t soa $Z +short|cut -d " " -f1`
echo $MASTER
[ -z "$MASTER" ] && echo "Error: Read Master Failed!" && exit 1
LOG=/tmp/zonesnchange.log

LSNOLD=/tmp/LSNOLD.tmp
RSNOLD=/tmp/RSNOLD.tmp

LSNO=`cat $LSNOLD`
RSNO=`cat $RSNOLD`
LSN=`dig @localhost -t soa $Z +short|cut -d " " -f3`
[ "$LSN" != "$LSNO" ] && echo $LSN >$LSNOLD && echo "`date` $Z SN on localhost changed from $LSNO to $LSN" >>$LOG 
RSN=`dig @$MASTER -t soa $Z +short|cut -d " " -f3`
[ "$RSN" != "$RSNO" ] && echo $RSN >$RSNOLD && echo "`date` $Z SN on $MASTER changed from $RSNO to $RSN" >>$LOG 
tail -10 $LOG
